package com.gostudy.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.gostudy.common.valid.AddGroup;
import com.gostudy.common.valid.ListValue;
import com.gostudy.common.valid.UpdateGroup;
import com.gostudy.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author 53Hertz
 * @email lizhenwei188@foxmail.com
 * @date 2021-04-03 14:46:40
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@TableId
	@NotNull(message = "修改的时候品牌id必须不能为空",groups = {UpdateGroup.class,UpdateStatusGroup.class})
	@Null(message = "新增加的时候品牌id必须为空",groups = AddGroup.class)
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌必须要有名称",groups = {AddGroup.class}) // 至少有一个非空格字符
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(message = "logo不能为空",groups = AddGroup.class)
	@URL(message = "logo必须是一个合法的url地址才可以",groups = {UpdateGroup.class,AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 * 自定义校验注解
	 */
	@NotNull(groups = {AddGroup.class, UpdateStatusGroup.class},message = "状态不能为空")
	@ListValue(vals={0,1},groups = {AddGroup.class, UpdateStatusGroup.class},message = "提交的值必须为0或者1")
	private Integer showStatus;
	/**
	 * 检索首字母,所有自定义的规则都可以用@Pattern()来声明，里面可以传入一个正则表达式
	 */
	@NotEmpty(groups = AddGroup.class)
	@Pattern(regexp = "^[a-zA-Z]$",message = "必须只能有一个字母",groups = {AddGroup.class,UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = AddGroup.class)
	@Min(value = 1,message = "排序最小为1",groups = {AddGroup.class,UpdateGroup.class})
	private Integer sort;

}
